package com.tg.data.http.entity;
import android.os.Parcel;
import android.os.Parcelable;

import com.tange.base.toolkit.StringUtils;


public class UndisturbedBean implements Parcelable {
    private String on_off;
    private String start;
    private String end;

    public static UndisturbedBean buildUndisturbedBean(String start, String end, boolean check){
        UndisturbedBean undisturbedBean = new UndisturbedBean();
        if (StringUtils.isEmpty(start) || StringUtils.isEmpty(end)
                || !start.contains(":") || !end.contains(":")){
            undisturbedBean.setOn_off("off");
            return undisturbedBean;
        }

        if (start.startsWith("+")){
            start = start.replace("+", "");
        }
        if (end.startsWith("+")){
            end = end.replace("+", "");
        }

        if (start.length() != 5 || end.length() != 5){
            undisturbedBean.setOn_off("off");
            return undisturbedBean;
        }

        undisturbedBean.setOn_off(check? "on" : "off");
        undisturbedBean.setStart(start);
        undisturbedBean.setEnd(end);
        return undisturbedBean;
    }

    public UndisturbedBean() {
    }

    protected UndisturbedBean(Parcel in) {
        on_off = in.readString();
        start = in.readString();
        end = in.readString();
    }

    public static final Creator<UndisturbedBean> CREATOR = new Creator<UndisturbedBean>() {
        @Override
        public UndisturbedBean createFromParcel(Parcel in) {
            return new UndisturbedBean(in);
        }

        @Override
        public UndisturbedBean[] newArray(int size) {
            return new UndisturbedBean[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(on_off);
        dest.writeString(start);
        dest.writeString(end);
    }


    public String getOn_off() {
        return on_off;
    }

    public void setOn_off(String on_off) {
        this.on_off = on_off;
    }

    public String getStart() {
        return start;
    }

    public void setStart(String start) {
        this.start = start;
    }

    public String getEnd() {
        return end;
    }

    public void setEnd(String end) {
        this.end = end;
    }
}
